/*     */ package com.qmsk.business.manage.cust.controller;
/*     */ 
/*     */ import com.qmsk.business.manage.cust.dao.CustDAO;
/*     */ import com.qmsk.business.manage.cust.dao.CustShopDAO;
/*     */ import com.qmsk.business.manage.mpCity.dao.MpCityDAO;
/*     */ import com.qmsk.business.member.member.dao.MemberDAO;
/*     */ import com.qmsk.business.member.member.params.MemberState;
/*     */ import com.qmsk.business.member.memberLevel.dao.MemberLevelDAO;
/*     */ import com.qmsk.business.member.memberLog.dao.MemberLogDAO;
/*     */ import com.qmsk.business.member.memberServiceBill.dao.MemberServiceBillDAO;
/*     */ import com.qmsk.business.member.memberServiceBillDetail.dao.MemberServiceBillDetailDAO;
/*     */ import com.qmsk.business.member.memberServiceDetail.dao.MemberServiceDetailDAO;
/*     */ import com.qmsk.business.member.shopMember.dao.ShopMemberDAO;
/*     */ import com.qmsk.business.shopList.ShopMap;
/*     */ import com.qmsk.business.weixin.customMenu.customer.CustomerInfo;
/*     */ import com.qmsk.business.weixin.customMenu.wxMapUtils.WxMapUtils;
/*     */ import com.qmsk.session.UserSessionInfo;
/*     */ import com.utils.basic.CDateTimeComm;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.basic.ObjectComm;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.gson.out.GsonEbRstLong;
/*     */ import com.utils.http.HttpGsonPtResponseUtils;
/*     */ import com.utils.http.HttpGsonPtUtils;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.commons.lang.StringUtils;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/cust"})
/*     */ public class CustController
/*     */ {
/*  53 */   private static final Logger logger = Logger.getLogger(CustController.class);
/*     */ 
/*     */   @Autowired
/*     */   private CustDAO dao;
/*     */ 
/*     */   @Autowired
/*     */   private CustShopDAO custShopDao;
/*     */ 
/*     */   @Autowired
/*     */   private MpCityDAO mpCityDAO;
/*     */ 
/*     */   @Autowired
/*     */   private MemberDAO memberDao;
/*     */ 
/*     */   @Autowired
/*     */   private MemberLevelDAO memberLeveldao;
/*     */ 
/*     */   @Autowired
/*     */   private ShopMemberDAO shopMemberDAO;
/*     */ 
/*     */   @Autowired
/*     */   private MemberServiceBillDAO memberServiceBillDAO;
/*     */ 
/*     */   @Autowired
/*     */   private MemberServiceBillDetailDAO memberServiceBillDetailDAO;
/*     */ 
/*     */   @Autowired
/*     */   private MemberServiceDetailDAO memberServiceDetailDAO;
/*     */ 
/*     */   @Autowired
/*     */   private MemberLogDAO memberLogDAO;
/*     */ 
/*     */   @RequestMapping(value={"find/baseinfo"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getMpAndNameByOpenId(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 110 */       String openId = RequestUtils.getString(request, "openId");
/* 111 */       GsonEbRst gsonEbRst = this.dao.getMpAndNameByOpenId(openId);
/* 112 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 114 */       logger.error(e);
/* 115 */       ResponseUtils.setErrorMsgResponse(
/* 116 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 134 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 136 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(shopId, nPageIdx, 
/* 137 */         nPageSize);
/* 138 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 140 */       logger.error(e);
/* 141 */       ResponseUtils.setErrorMsgResponse(
/* 142 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/opt1/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListCustCar(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 152 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 154 */       Map params = new HashMap();
/* 155 */       MapUtils.addToMap(params, "shopId", shopId);
/* 156 */       MapUtils.addPercentToMap(params, "mp", 
/* 157 */         RequestUtils.getString(request, "mp"));
/* 158 */       MapUtils.addPercentToMap(params, "custName", 
/* 159 */         RequestUtils.getString(request, "custName"));
/* 160 */       MapUtils.addPercentToMap(params, "tel", 
/* 161 */         RequestUtils.getString(request, "tel"));
/*     */ 
/* 164 */       MapUtils.addPercentToMap(params, "CardNo", 
/* 165 */         RequestUtils.getString(request, "CardNo"));
/* 166 */       MapUtils.addPercentToMap(params, "idNum", 
/* 167 */         RequestUtils.getString(request, "idNum"));
/* 168 */       MapUtils.addPercentToMap(params, "addr", 
/* 169 */         RequestUtils.getString(request, "addr"));
/* 170 */       MapUtils.addToMap(params, "dtBirthBegin", 
/* 171 */         RequestUtils.getDate(request, "dtBirthBegin"));
/* 172 */       MapUtils.addToMap(params, "dtBirthEnd", 
/* 173 */         RequestUtils.getDate(request, "dtBirthEnd"));
/* 174 */       MapUtils.addToMap(params, "custId", 
/* 175 */         RequestUtils.getInt(request, "custId"));
/* 176 */       MapUtils.addToMap(params, "levelId", 
/* 177 */         RequestUtils.getInt(request, "levelId"));
/* 178 */       MapUtils.addToMap(params, "status", Integer.valueOf(2));
/* 179 */       GsonEbRst gsonEbRst = null;
/* 180 */       gsonEbRst = this.dao.getGsonOfShopIdOpt2(params, nPageIdx, nPageSize);
/* 181 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 183 */       logger.error(e);
/* 184 */       ResponseUtils.setErrorMsgResponse(
/* 185 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/opt2/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getInfoListCust(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 195 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 197 */       Integer range = RequestUtils.getInt(request, "range", Integer.valueOf(2));
/* 198 */       GsonEbRst gsonEbRst = null;
/*     */       Map params;
/* 199 */       if (range.intValue() == 0) {
/* 200 */         params = new HashMap();
/*     */ 
/* 202 */         MapUtils.addToMap(params, "shopId", shopId);
/* 203 */         gsonEbRst = this.dao
/* 204 */           .getCustNameOfShopId(params, nPageIdx, nPageSize);
/* 205 */       } else if (range.intValue() == 1) {
/* 206 */         params = new HashMap();
/*     */ 
/* 208 */         MapUtils.addToMap(params, "shopId", shopId);
/* 209 */         MapUtils.addToMap(params, "levelId", 
/* 210 */           RequestUtils.getInt(request, "levelId"));
/* 211 */         MapUtils.addToMap(params, "status", Integer.valueOf(2));
/* 212 */         gsonEbRst = this.memberDao.getCustNameOfShopId(params, nPageIdx, 
/* 213 */           nPageSize);
/* 214 */       } else if (range.intValue() == 2) {
/* 215 */         params = new HashMap();
/*     */ 
/* 217 */         MapUtils.addToMap(params, "shopId", shopId);
/* 218 */         MapUtils.addPercentToMap(params, "mp", 
/* 219 */           RequestUtils.getString(request, "mp"));
/* 220 */         MapUtils.addPercentToMap(params, "custName", 
/* 221 */           RequestUtils.getString(request, "name"));
/* 222 */         MapUtils.addPercentToMap(params, "tel", 
/* 223 */           RequestUtils.getString(request, "tel"));
/* 224 */         MapUtils.addPercentToMap(params, "addr", 
/* 225 */           RequestUtils.getString(request, "addr"));
/* 226 */         MapUtils.addToMap(params, "dtBirthBegin", 
/* 227 */           RequestUtils.getDate(request, "dtBirthBegin"));
/* 228 */         MapUtils.addToMap(params, "dtBirthEnd", 
/* 229 */           RequestUtils.getDate(request, "dtBirthEnd"));
/* 230 */         MapUtils.addToMap(params, "custId", 
/* 231 */           RequestUtils.getInt(request, "custId"));
/* 232 */         gsonEbRst = this.dao
/* 233 */           .getCustNameOfShopId(params, nPageIdx, nPageSize);
/*     */       }
/* 235 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 237 */       logger.error(e);
/* 238 */       ResponseUtils.setErrorMsgResponse(
/* 239 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/carId/{shopId}/{carId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListShopIdCarId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("carId") Integer carId)
/*     */   {
/*     */     try
/*     */     {
/* 258 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopIdCarId(shopId, carId);
/* 259 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 261 */       logger.error(e);
/* 262 */       ResponseUtils.setErrorMsgResponse(
/* 263 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insertList(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/* 281 */       int nResult = 0;
/* 282 */       Long id = null;
/* 283 */       Long outId = null;
/* 284 */       String custName = null;
/* 285 */       Long outMId = null;
/* 286 */       String cardNo = null;
/* 287 */       Long outSId = ShopMap.getOutIdOfShopId(shopId);
/* 288 */       String sData = RequestUtils.getStringOfData(request);
/* 289 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 290 */       if (p != null)
/*     */       {
/*     */         int i;
/*     */         GsonHeadOneRow r;
/*     */         String mp;
/*     */         Long count;
/*     */         String StrNum;
/* 291 */         if (p.isExistsInsertRows()) {
/* 292 */           for (i = 0; i < p.getListInsertRows().size(); ++i) {
/* 293 */             r = (GsonHeadOneRow)p.getListInsertRows().get(i);
/* 294 */             if (r != null) {
/* 295 */               mp = (String)r.getValueOfName("Mp");
/* 296 */               if (mp != null) {
/* 297 */                 count = this.dao.getUserIdOfMp(mp);
/* 298 */                 if (count.longValue() > 0L) {
/* 299 */                   ResponseUtils.setErrorMsgResponse("手机号码为" + 
/* 300 */                     mp + "的客户已存在", response);
/* 301 */                   return;
/*     */                 }
/* 303 */                 StrNum = StringUtils.substring(mp, 0, 7);
/* 304 */                 if (!(this.mpCityDAO.getCheckMp(StrNum).booleanValue())) {
/* 305 */                   ResponseUtils.setErrorMsgResponse(
/* 306 */                     "手机号码不合法", response);
/* 307 */                   return;
/*     */                 }
/*     */               }
/*     */ 
/* 311 */               custName = (String)r.getValueOfName("name");
/* 312 */               r.autoAddHeadData("Status", Integer.valueOf(0));
/* 313 */               r.autoAddHeadData("CreateFileTime", new Date());
/* 314 */               if ((outSId != null) && (outSId.longValue() > 0L)) {
/* 315 */                 outId = getPtCustIdOfInsertPt(
/* 316 */                   r.objectToJsonStr(), 
/* 317 */                   String.valueOf(outSId), response);
/* 318 */                 if ((outId == null) || (outId.longValue() <= 0L))
/* 319 */                   logger.error("获取outId失败");
/*     */                 else
/* 321 */                   r.autoAddHeadData("outId", outId);
/*     */               }
/*     */             }
/*     */             else {
/* 325 */               ResponseUtils.setErrorMsgResponse("没有请求参数", 
/* 326 */                 response);
/* 327 */               return;
/*     */             }
/*     */           }
/*     */         }
/* 331 */         if (p.isExistsUpdateRows()) {
/* 332 */           for (i = 0; i < p.getListUpdateRows().size(); ++i) {
/* 333 */             r = (GsonHeadOneRow)p.getListUpdateRows().get(i);
/* 334 */             mp = (String)r.getValueOfName("Mp");
/* 335 */             if ((r != null) && (mp != null)) {
/* 336 */               count = this.dao.getUserIdOfMp(mp);
/* 337 */               if (count.longValue() > 0L) {
/* 338 */                 ResponseUtils.setErrorMsgResponse("手机号码为" + mp + 
/* 339 */                   "的客户已存在", response);
/* 340 */                 return;
/*     */               }
/* 342 */               StrNum = StringUtils.substring(mp, 0, 7);
/* 343 */               if (!(this.mpCityDAO.getCheckMp(StrNum).booleanValue())) {
/* 344 */                 ResponseUtils.setErrorMsgResponse("手机号码不合法", 
/* 345 */                   response);
/* 346 */                 return;
/*     */               }
/*     */             }
/*     */           }
/*     */         }
/*     */ 
/* 352 */         nResult = this.dao.applyUpdates(p, "id");
/* 353 */         if ((p.isExistsInsertRows()) && (nResult > 0)) {
/* 354 */           GsonHeadOneRow r1 = (GsonHeadOneRow)p.getListInsertRows().get(0);
/* 355 */           id = ObjectComm.objectToLong(r1.getValueOfName("id"));
/* 356 */           if ((id != null) && (id.longValue() > 0L)) {
/* 357 */             nResult = this.custShopDao.insertParams(new Object[] { 
/* 358 */               shopId, id }).intValue();
/*     */ 
/* 359 */             if (nResult <= 0) {
/* 360 */               DbConnection.rollback();
/* 361 */               ResponseUtils.setErrorMsgResponse("custShop添加失败", 
/* 362 */                 response);
/* 363 */               return;
/*     */             }
/*     */           }
/*     */         }
/*     */       }
/* 368 */       if ((nResult > 0) || (p == null) || (p.isExistsRows())) {
/* 369 */         ParserDataSetJson pMember = 
/* 370 */           ParserDataSetJson.fromString(RequestUtils.getString(request, "member"));
/* 371 */         if (pMember != null) {
/* 372 */           Long groupId = RequestUtils.getLong(request, "groupId");
/* 373 */           String createFileMan = 
/* 374 */             UserSessionInfo.getUserNameOfRequest(request);
/* 375 */           Long lMemberId = Long.valueOf(0L);
/* 376 */           Date greatTime = null;
/* 377 */           Date validDateTmie = null;
/* 378 */           Long levelID = Long.valueOf(0L);
/* 379 */           Integer validDay = Integer.valueOf(0);
/* 380 */           if (pMember.isExistsInsertRows()) {
/* 381 */             for (int i = 0; i < pMember.getListInsertRows().size(); ++i) {
/* 382 */               GsonHeadOneRow g = (GsonHeadOneRow)pMember.getListInsertRows().get(
/* 383 */                 i);
/* 384 */               if (id != null) {
/* 385 */                 g.autoAddHeadData("CustID", id);
/*     */               }
/* 387 */               g.autoAddHeadData("status", Integer.valueOf(1));
/* 388 */               g.autoAddHeadData("CreateFileTime", new Date());
/* 389 */               g.encryptHead("payPwd");
/* 390 */               levelID = ObjectComm.objectToLong(
/* 391 */                 g.getValueOfName("LevelId"), Long.valueOf(0L));
/* 392 */               if ((levelID != null) && (levelID.longValue() > 0L)) {
/* 393 */                 validDay = Integer.valueOf(this.memberLeveldao.getValidDay(shopId, 
/* 394 */                   levelID));
/* 395 */                 if (validDay.intValue() <= 0)
/* 396 */                   g.autoAddHeadData("ValidDateTime", 
/* 397 */                     CDateTimeComm.getAddYear(
/* 398 */                     new Date(), 100));
/*     */                 else {
/* 400 */                   g.autoAddHeadData("ValidDateTime", 
/* 401 */                     CDateTimeComm.getAddDate(
/* 402 */                     new Date(), validDay.intValue()));
/*     */                 }
/*     */               }
/* 405 */               greatTime = (Date)g
/* 406 */                 .getValueOfName("CreateFileTime");
/* 407 */               validDateTmie = (Date)g
/* 408 */                 .getValueOfName("ValidDateTime");
/* 409 */               String memberCardNo = (String)g
/* 410 */                 .getValueOfName("MemberCardNo");
/* 411 */               if ((memberCardNo != null) && (memberCardNo != "")) {
/* 412 */                 int count = this.memberDao.getCardNoIsExsit(
/* 413 */                   memberCardNo, shopId);
/* 414 */                 if (count >= 1) {
/* 415 */                   DbConnection.rollback();
/* 416 */                   ResponseUtils.setErrorMsgResponse(
/* 417 */                     "已有相同的会员卡号", response);
/* 418 */                   return;
/*     */                 }
/*     */               }
/*     */ 
/* 422 */               if ((outSId != null) && (outSId.longValue() > 0L)) {
/* 423 */                 outMId = getMemberIdPtLong(g.objectToJsonStr(), 
/* 424 */                   outSId, groupId, outId, response);
/* 425 */                 if ((outMId == null) || (outMId.longValue() <= 0L))
/* 426 */                   logger.error("获取outMId失败");
/*     */                 else {
/* 428 */                   g.autoAddHeadData("outMId", outMId);
/*     */                 }
/*     */ 
/*     */               }
/*     */ 
/*     */             }
/*     */ 
/*     */           }
/*     */ 
/* 439 */           nResult = this.memberDao.applyUpdates(pMember, "id");
/* 440 */           if ((pMember.isExistsInsertRows()) && (nResult > 0)) {
/* 441 */             GsonHeadOneRow r = (GsonHeadOneRow)pMember.getListInsertRows().get(0);
/* 442 */             lMemberId = ObjectComm.objectToLong(r
/* 443 */               .getValueOfName("id"));
/* 444 */             if ((lMemberId != null) && (lMemberId.longValue() > 0L)) {
/* 445 */               cardNo = ShopMap.getCardFlagOfShopId(shopId) + 
/* 446 */                 String.valueOf(lMemberId);
/* 447 */               nResult = this.memberDao.updateCardNoOfId(cardNo, 
/* 448 */                 outMId, lMemberId);
/* 449 */               String ssss = RequestUtils.getString(request, 
/* 450 */                 "memLogData");
/* 451 */               this.memberLogDAO.insertMemberLog1(lMemberId, ssss);
/* 452 */               nResult = saveAfter(lMemberId, validDay, shopId, 
/* 453 */                 groupId, createFileMan, custName, levelID, 
/* 454 */                 greatTime, validDateTmie, true, "", cardNo);
/*     */             }
/*     */           }
/*     */         }
/*     */       }
/*     */ 
/* 460 */       if (nResult > 0)
/* 461 */         DbConnection.commit();
/*     */       else {
/* 463 */         DbConnection.rollback();
/*     */       }
/*     */ 
/* 466 */       if ((id == null) || (id.longValue() <= 0L)) {
/* 467 */         ResponseUtils.setSqlResultResponse(nResult, 
/* 468 */           RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 469 */           response);
/* 470 */         return; }
/* 471 */       ResponseUtils.setResponseResult(id, response);
/*     */     }
/*     */     catch (Exception e) {
/* 474 */       DbConnection.rollback();
/* 475 */       logger.error(e);
/* 476 */       ResponseUtils.setErrorMsgResponse(
/* 477 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 478 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"insert/wxInfo"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insertWxInfo(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 494 */     String jsonData = RequestUtils.getStringOfData(request);
/*     */     try {
/* 496 */       int nRust = 0;
/* 497 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(jsonData);
/* 498 */       String mp = (String)g.getValueOfName("mp");
/* 499 */       if (mp != null) {
/* 500 */         Long shopId = ObjectComm.objectToLong(RequestUtils.getLong(
/* 501 */           request, "shopId"));
/* 502 */         Long custId = this.memberDao.getIsMember(mp, shopId);
/* 503 */         if (custId.longValue() > 0L) {
/* 504 */           String openId = (String)g.getValueOfName("openId");
/* 505 */           String wxCard = (String)g.getValueOfName("wxCardNo");
/* 506 */           if (openId != null) {
/* 507 */             if (this.dao.getIsMemberOfCust(shopId, openId)) {
/* 508 */               ResponseUtils.setErrorMsgResponse(
/* 509 */                 "您已绑定过实体卡,谢谢您这么热情", response);
/* 510 */               return;
/*     */             }
/* 512 */             if (this.dao.getIsWxcardNo(wxCard)) {
/* 513 */               ResponseUtils.setErrorMsgResponse("该卡号已经被绑定请换张卡", 
/* 514 */                 response);
/* 515 */               return;
/*     */             }
/* 517 */             g.delHead("mp");
/* 518 */             g.addHeadData("wxCreateTime", new Date());
/* 519 */             g.addHeadData("CustFrom", Integer.valueOf(3));
/* 520 */             nRust = this.dao.updateJsonOneRow(g, custId);
/* 521 */            
/*     */           }
/* 523 */           ResponseUtils.setErrorMsgResponse("系统忙，请稍后再试", response);
/* 524 */           return;
/*     */         }
/*     */ 
/* 527 */         ResponseUtils.setErrorMsgResponse(
/* 528 */           "您还不是会员，请先注册会员或是您的会员非正常状态", response);
/* 529 */         return;
/*     */       }
/*     */ 
/* 532 */       if (nRust > 0) {
/* 533 */         label203: DbConnection.commit();
/* 534 */         ResponseUtils.setSqlResultResponse(nRust, 
/* 535 */           RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 536 */           response);
/*     */ 
/* 538 */         return; }
/* 539 */       DbConnection.rollback();
/* 540 */       ResponseUtils.setErrorMsgResponse("绑定失败", response);
/*     */     }
/*     */     catch (SQLException e) {
/* 543 */       DbConnection.rollback();
/* 544 */       logger.error(e);
/* 545 */       ResponseUtils.setErrorMsgResponse("绑定失败", response);
/*     */     }
/*     */   }
/*     */ 
/*     */   private Long getMemberIdPtLong(String sGsonInData, Long shopId, Long groupId, Long outId, HttpServletResponse response)
/*     */     throws Exception
/*     */   {
/* 552 */     GsonHeadOneRow gs = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 553 */     GsonEbRstLong rst = null;
/* 554 */     if (gs != null) {
/* 555 */       String[] delHead = { "OperatorID", "ValidDateTime", 
/* 556 */         "MemberMemo", "SaleId", "MemberFee", "Modified" };
/* 557 */       gs.delHead(delHead);
/* 558 */       if (gs.getDataLength() > 0) {
/* 559 */         Integer status = (Integer)gs.getValueOfName("Status");
/* 560 */         if (status != null) {
/* 561 */           String nStatus = MemberState.getState(status);
/* 562 */           gs.setValueOfName("Status", nStatus);
/*     */         }
/* 564 */         String sSendToPt = gs.objectToJsonStr();
/* 565 */         String sData = "data=" + sSendToPt + "&shopId=" + 
/* 566 */           shopId + "&groupId=" + groupId + "&outId=" + outId;
/* 567 */         String sUrl = "ptmember/insert";
/* 568 */         rst = HttpGsonPtUtils.getEbRstLong(sUrl, sData, response);
/*     */       }
/* 570 */       if (rst != null) {
/* 571 */         return rst.getResult();
/*     */       }
/* 573 */       return null;
/*     */     }
/*     */ 
/* 576 */     ResponseUtils.setErrorMsgResponse("获取Crm信息失败", response);
/* 577 */     return null;
/*     */   }
/*     */ 
/*     */   private int saveAfter(Long lMemberId, Integer validDay, Long shopId, Long groupId, String createFileMan, String serviceMan, Object LevelID, Date greatTime, Date validayTime, boolean bDeleteHis, String memo, String cardNo)
/*     */     throws SQLException
/*     */   {
/* 585 */     int nResult = 0;
/* 586 */     String[] heads = { "MemberID", "ShopID", "IsCreateShop", 
/* 587 */       "GroupId", "DepositAmount", "IntegralAmount", "ConsumeAmount", 
/* 588 */       "CashCouponAmount", "CouponAmount", "ValidDateTime", "LevelID", 
/* 589 */       "MemberCardNo", "ValidDay", "Status" };
/* 590 */     Object[] datas = { lMemberId, shopId, Boolean.valueOf(true), groupId, Double.valueOf(0.0D), 
/* 591 */       Double.valueOf(0.0D), Double.valueOf(0.0D), Double.valueOf(0.0D), Double.valueOf(0.0D), validayTime, LevelID, cardNo, validDay, 
/* 592 */       Integer.valueOf(1) };
/* 593 */     GsonHeadOneRow g = new GsonHeadOneRow(heads, datas);
/* 594 */     if ((this.shopMemberDAO.insertGsonHeadOneRow(g) > 0) && 
/* 595 */       (this.memberServiceBillDAO.insertBill(lMemberId, createFileMan, 
/* 596 */       serviceMan, shopId, memo).intValue() > 0))
/*     */     {
/* 597 */       Long billId = this.memberServiceBillDAO.getLastId();
/* 598 */       this.memberServiceBillDetailDAO.insertBillDetail(lMemberId, billId, 
/* 599 */         LevelID, shopId);
/* 600 */       this.memberServiceDetailDAO.insertDetail(validDay, greatTime, 
/* 601 */         validayTime, lMemberId, shopId, LevelID, bDeleteHis);
/* 602 */       nResult = 1;
/*     */     }
/*     */ 
/* 605 */     return nResult;
/*     */   }
/*     */ 
/*     */   private Long getPtCustIdOfInsertPt(String sGsonInData, String shopId, HttpServletResponse response) throws Exception
/*     */   {
/* 610 */     String sData = "data=" + sGsonInData + "&" + "shopId" + 
/* 611 */       "=" + shopId;
/* 612 */     String url = "ptcust/insert";
/* 613 */     GsonEbRstLong rst = HttpGsonPtUtils.getEbRstLong(url, sData, response);
/* 614 */     if (rst != null) {
/* 615 */       return rst.getResult();
/*     */     }
/* 617 */     return null;
/*     */   }
/*     */ 
/*     */   private GsonEbRst getPtCustDelEbRst(Long outId, Object shopId, HttpServletResponse response)
/*     */     throws Exception
/*     */   {
/* 623 */     String sData = "id=" + outId.toString() + "&shopId=" + 
/* 624 */       shopId;
/* 625 */     GsonEbRst rst = HttpGsonPtResponseUtils.postPtEbRst("ptcust/del", 
/* 626 */       sData, response);
/* 627 */     if (rst != null) {
/* 628 */       return rst;
/*     */     }
/* 630 */     return null;
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/* 647 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 649 */       Long outId = this.dao.getIsOutId(id);
/* 650 */       if (outId.longValue() > 0L) {
/* 651 */         GsonEbRst rst = getPtCustDelEbRst(outId, shopId, response);
/* 652 */         if ((rst == null) || (rst.getState() != 0)) {
/* 653 */           logger.error("outId删除失败");
/*     */         }
/*     */       }
/* 656 */       String[] strParams = id.split(",");
/* 657 */       int nResult = this.dao.deleteParams(strParams);
/* 658 */       if (nResult > 0) {
/* 659 */         nResult = this.custShopDao.deleteParams(strParams);
/*     */       }
/* 661 */       if (nResult > 0)
/* 662 */         DbConnection.commit();
/*     */       else {
/* 664 */         DbConnection.rollback();
/*     */       }
/* 666 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 667 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 668 */         response);
/*     */     } catch (Exception e) {
/* 670 */       DbConnection.rollback();
/* 671 */       logger.error(e);
/* 672 */       ResponseUtils.setErrorMsgResponse(
/* 673 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 674 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"edit/updateImageUrlByOpenId"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void updateImageUrlByOpenId(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 683 */       String openId = ObjectComm.objectToString(request.getParameter("openId"));
/*     */ 
/* 685 */       CustomerInfo c = WxMapUtils.getCustInfoOfOpenId(openId);
/* 686 */       String imageUrl = c.getHeadimgurl();
/* 687 */       int nResult = this.dao.updateImageUrlByOpenId(imageUrl, openId);
/* 688 */       if (nResult > 0) {
/* 689 */         String[] head = { "imageUrl" };
/* 690 */         Object[] data = { imageUrl };
/* 691 */         ResponseUtils.toGsonEbRst(head, data, response);
/* 692 */         return; }
/* 693 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 694 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 695 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 698 */       DbConnection.rollback();
/* 699 */       logger.error(e);
/* 700 */       ResponseUtils.setErrorMsgResponse(
/* 701 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 702 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/findImageUrlByOpenId"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void findImageUrlByOpenId(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 711 */       String openId = ObjectComm.objectToString(request.getParameter("openId"));
/*     */ 
/* 713 */       CustomerInfo c = WxMapUtils.getCustInfoOfOpenId(openId);
/* 714 */       String imageUrl = c.getHeadimgurl();
/* 715 */       String name = c.getNickname();
/* 716 */       String[] head = { "imageUrl", "name" };
/* 717 */       Object[] data = { imageUrl, name };
/* 718 */       ResponseUtils.toGsonEbRst(head, data, response);
/*     */     } catch (Exception e) {
/* 720 */       logger.error(e);
/* 721 */       ResponseUtils.setErrorMsgResponse(
/* 722 */         RequestUtils.getFindDataErrorMessage(request) + ":" + 
/* 723 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.manage.cust.controller.CustController
 * JD-Core Version:    0.5.3
 */